<?php

namespace App\Models;

class AreaModel
{
    public static function getAreaList($conn,$AreaExample){
        if($AreaExample->parentId != null){
            $areaSql="select `id`,`areaCode`,`areaName`,`level`,`parentId` FROM `area` WHERE `parentId` = $AreaExample->parentId";
        }else{
            $areaSql="select `id`,`areaCode`,`areaName`,`level`,`parentId` FROM `area` WHERE `level` = 1";
        }
        return $conn->readConn($areaSql,true);
    }
    public static function getArea($conn,$id){
        $areaSql="select `id`,`areaCode`,`areaName`,`level`,`parentId` FROM `area` WHERE `id` = $id";
        return $conn->readConn($areaSql);
    }
}